/**
 * The main application class. An instance of this class is created by app.js when it
 * calls Ext.application(). This is the ideal place to handle application launch and
 * initialization details.
 */
Ext.define('extjs6test.Application', {
    extend: 'Ext.app.Application',

    name: 'extjs6test',

    stores: [
        'extjs6test.store.LoginData'
    ],
    requires: [
        'extjs6test.view.Login',
        'Ext.util.LocalStorage'
    ],
    getRequestBaseUrl:function () {
       return "http://localhost:9000";
    },
    launch: function () {
        Ext.tip.QuickTipManager.init();

        var loginStore = this.getStore('LoginData');
        var viewport=Ext.create({xtype:'viewport',layout:'fit'});
        loginStore.load();
        if (!loginStore.count()) {
            viewport.add({xtype:'extjsdemologin'});
        }
        else {
            viewport.add({xtype:'app-main'});
        }
    },

    onAppUpdate: function () {
        Ext.Msg.confirm('Application Update', 'This application has an update, reload?',
            function (choice) {
                if (choice === 'yes') {
                    window.location.reload();
                }
            }
        );
    }
});
